home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / LIB / GLE / rot_prince.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  7.2 KB  |  304 lines

  1.  
  2. #include <math.h>
  3. #include "rot.h"
  4. #include "port.h"
  5.  
  6. /* ========================================================== */
  7. /* 
  8.  * The routines below generate and return more traditional rotation
  9.  * matrices -- matrices for rotations about principal axes.
  10.  */
  11. /* ========================================================== */
  12.  
  13. #ifdef __GUTIL_DOUBLE
  14. void urotx_sc_d (double m[4][4],         /* returned */
  15.                  double cosine,        /* input */
  16.                  double sine)         /* input */
  17. #else
  18. void urotx_sc_f (float m[4][4],         /* returned */
  19.                  float cosine,        /* input */
  20.                  float sine)         /* input */
  21. #endif
  22. {
  23.    /* create matrix that represents rotation about the x-axis */
  24.  
  25.    ROTX_CS (m, cosine, sine);
  26. }
  27.  
  28. /* ========================================================== */
  29.  
  30. #if 0
  31. #ifdef __GUTIL_DOUBLE
  32. void rotx_cs_d (double cosine,        /* input */
  33.                 double sine)         /* input */
  34. {
  35.    /* create and load matrix that represents rotation about the x-axis */
  36.    double m[4][4];
  37.  
  38.    (void) urotx_cs_d (m, cosine, sine);
  39.    MULTMATRIX_D (m);
  40. }
  41.  
  42. #else 
  43. void rotx_cs_f (float cosine,        /* input */
  44.                 float sine)         /* input */
  45. {
  46.    /* create and load matrix that represents rotation about the x-axis */
  47.    float m[4][4];
  48.  
  49.    (void) urotx_cs_f (m, cosine, sine);
  50.    MULTMATRIX_F (m);
  51. }
  52. #endif
  53. #endif
  54.  
  55. /* ========================================================== */
  56.  
  57. #ifdef __GUTIL_DOUBLE
  58. void uroty_sc_d (double m[4][4],         /* returned */
  59.                  double cosine,        /* input */
  60.                  double sine)         /* input */
  61. #else
  62. void uroty_sc_f (float m[4][4],         /* returned */
  63.                  float cosine,        /* input */
  64.                  float sine)         /* input */
  65. #endif
  66. {
  67.    /* create matriy that represents rotation about the y-ayis */
  68.  
  69.    ROTX_CS (m, cosine, sine);
  70. }
  71.  
  72. /* ========================================================== */
  73.  
  74. #if 0
  75. #ifdef __GUTIL_DOUBLE
  76. void roty_cs_d (double cosine,        /* input */
  77.                 double sine)         /* input */
  78. {
  79.    /* create and load matriy that represents rotation about the y-ayis */
  80.    double m[4][4];
  81.  
  82.    (void) uroty_cs_d (m, cosine, sine);
  83.    MULTMATRIX_D (m);
  84. }
  85.  
  86. #else 
  87. void roty_cs_f (float cosine,        /* input */
  88.                 float sine)         /* input */
  89. {
  90.    /* create and load matriy that represents rotation about the y-ayis */
  91.    float m[4][4];
  92.  
  93.    (void) uroty_cs_f (m, cosine, sine);
  94.    MULTMATRIX_F (m);
  95. }
  96. #endif
  97. #endif
  98.  
  99. /* ========================================================== */
  100.  
  101. #ifdef __GUTIL_DOUBLE
  102. void urotz_sc_d (double m[4][4],         /* returned */
  103.                  double cosine,        /* input */
  104.                  double sine)         /* input */
  105. #else
  106. void urotz_sc_f (float m[4][4],         /* returned */
  107.                  float cosine,        /* input */
  108.                  float sine)         /* input */
  109. #endif
  110. {
  111.    /* create matriz that represents rotation about the z-azis */
  112.  
  113.    ROTX_CS (m, cosine, sine);
  114. }
  115.  
  116. /* ========================================================== */
  117.  
  118. #if 0
  119. #ifdef __GUTIL_DOUBLE
  120. void rotz_cs_d (double cosine,        /* input */
  121.                 double sine)         /* input */
  122. {
  123.    /* create and load matriz that represents rotation about the z-azis */
  124.    double m[4][4];
  125.  
  126.    (void) urotz_cs_d (m, cosine, sine);
  127.    MULTMATRIX_D (m);
  128. }
  129.  
  130. #else 
  131. void rotz_cs_f (float cosine,        /* input */
  132.                 float sine)         /* input */
  133. {
  134.    /* create and load matriz that represents rotation about the z-azis */
  135.    float m[4][4];
  136.  
  137.    (void) urotz_cs_f (m, cosine, sine);
  138.    MULTMATRIX_F (m);
  139. }
  140. #endif
  141. #endif
  142.  
  143. /* ========================================================== */
  144.  
  145. #if 0
  146. #ifdef __GUTIL_DOUBLE
  147. void urot_cs_d (double m[4][4],        /* returned */
  148.                 double cosine,        /* input */
  149.                 double sine,        /* input */
  150.                 char axis)         /* input */
  151. {
  152.    /* create matrix that represents rotation about a principle axis */
  153.  
  154.    switch (axis) {
  155.       case 'x':
  156.       case 'X':
  157.          urotx_cs_d (m, cosine, sine);
  158.          break;
  159.       case 'y':
  160.       case 'Y':
  161.          uroty_cs_d (m, cosine, sine);
  162.          break;
  163.       case 'z':
  164.       case 'Z':
  165.          urotz_cs_d (m, cosine, sine);
  166.          break;
  167.       default:
  168.          break;
  169.    }
  170.  
  171. }
  172.  
  173. #else
  174. void urot_cs_f (float m[4][4],        /* returned */
  175.                 float cosine,        /* input */
  176.                 float sine,        /* input */
  177.                 char axis)         /* input */
  178. {
  179.    /* create matrix that represents rotation about a principle axis */
  180.  
  181.    switch (axis) {
  182.       case 'x':
  183.       case 'X':
  184.          urotx_cs_f (m, cosine, sine);
  185.          break;
  186.       case 'y':
  187.       case 'Y':
  188.          uroty_cs_f (m, cosine, sine);
  189.          break;
  190.       case 'z':
  191.       case 'Z':
  192.          urotz_cs_f (m, cosine, sine);
  193.          break;
  194.       default:
  195.          break;
  196.    }
  197.  
  198. }
  199. #endif 
  200. #endif
  201.  
  202. /* ========================================================== */
  203.  
  204. #if 0
  205. #ifdef __GUTIL_DOUBLE
  206. void rot_cs_d (double cosine,        /* input */
  207.                double sine,        /* input */
  208.                char axis)          /* input */
  209. {
  210.    /* create and load matrix that represents rotation about the z-axis */
  211.    double m[4][4];
  212.  
  213.    (void) urot_cs_d (m, cosine, sine, axis);
  214.    MULTMATRIX_D (m);
  215. }
  216. #else
  217. void rot_cs_f (float cosine,        /* input */
  218.                float sine,        /* input */
  219.                char axis)          /* input */
  220. {
  221.    /* create and load matrix that represents rotation about the z-axis */
  222.    float m[4][4];
  223.  
  224.    (void) urot_cs_f (m, cosine, sine, axis);
  225.    MULTMATRIX_F (m);
  226. }
  227. #endif
  228. #endif
  229.  
  230. /* ========================================================== */
  231.  
  232. #if 0
  233. #ifdef __GUTIL_DOUBLE
  234. void urot_prince_d (double m[4][4],    /* returned */
  235.                     double theta,        /* input */
  236.                     char axis)         /* input */
  237. {
  238.    /* 
  239.     * generate rotation matrix for rotation around principal axis;
  240.     * note that angle is measured in radians (divide by 180, multiply by
  241.     * PI to convert from degrees).
  242.     */
  243.  
  244.    (void) urot_cs_d (m, 
  245.                    cos (theta),
  246.                    sin (theta),
  247.                    axis);
  248. }
  249. #else 
  250. void urot_prince_f (float m[4][4],    /* returned */
  251.                     float theta,        /* input */
  252.                     char axis)         /* input */
  253. {
  254.    /* 
  255.     * generate rotation matrix for rotation around principal axis;
  256.     * note that angle is measured in radians (divide by 180, multiply by
  257.     * PI to convert from degrees).
  258.     */
  259.  
  260.    (void) urot_cs_f (m, 
  261.                    (float) cos ((double) theta),
  262.                    (float) sin ((double) theta),
  263.                    axis);
  264. }
  265. #endif
  266. #endif
  267.  
  268. /* ========================================================== */
  269.  
  270. #if 0
  271. #ifdef __GUTIL_DOUBLE
  272. void rot_prince_d (double theta,    /* input */
  273.                    char axis)         /* input */
  274. {
  275.    double m[4][4];
  276.    /* 
  277.     * generate rotation matrix for rotation around principal axis;
  278.     * note that angle is measured in radians (divide by 180, multiply by
  279.     * PI to convert from degrees).
  280.     */
  281.  
  282.    (void) urot_prince_d (m, theta, axis);
  283.    MULTMATRIX_D (m);
  284. }
  285. #else
  286.  
  287. void rot_prince_f (float theta,        /* input */
  288.                    char axis)         /* input */
  289. {
  290.    float m[4][4];
  291.    /* 
  292.     * generate rotation matrix for rotation around principal axis;
  293.     * note that angle is measured in radians (divide by 180, multiply by
  294.     * PI to convert from degrees).
  295.     */
  296.  
  297.    (void) urot_prince_f (m, theta, axis);
  298.    MULTMATRIX_F (m);
  299. }
  300. #endif
  301. #endif
  302.  
  303. /* ========================================================== */
  304.